<?php if (! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 用户验证 模型
 */

class Auth_model extends CI_Model {

    protected $_config;

    public function __construct() {
        parent::__construct();

        //加载配置
        $this->load->config('auth', true);
        if (count($this->config->item('auth')) > 0) {
            $this->_config = $this->config->item('auth');
        }

        log_message('debug', "Auth_model Model Class Initialized");
    }

    /**
     * 获取用户基本信息
     *
     * @param $field 查找字段
     * @param $value 查找的值
     * @return array
     */
    public function get_user_by($field, $value) {
        $fields = array(
            'uid',
            'username',
            'email');
        if (! in_array($field, $fields)) return array();

        $this->db->where($field, $value);
        return $this->db->get($this->_config['tables']['user'], 1)->row_array();
    }

}

/* End of file user_model.php */
/* Location: ./application/models/user_model.php */
